Showcasing RRPlots
Libraries
library(survival)
library(FRESA.CAD)
## Loading required package: Rcpp
## Loading required package: stringr
## Loading required package: miscTools
## Loading required package: Hmisc
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
## Loading required package: pROC
## Type 'citation("pROC")' for a citation.
##
## Attaching package: 'pROC'
## The following objects are masked from 'package:stats':
##
## cov, smooth, var
#source("~/GitHub/FRESA.CAD/R/RRPlot.R")
#source("~/GitHub/FRESA.CAD/R/PoissonEventRiskCalibration.R")
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
#pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
layout(matrix(1:1, nrow=1))
Wisconsin Data
Set
dataBreast <- read.csv("~/GitHub/RISKPLOTS/DATA/wpbc.data", header=FALSE)
table(dataBreast$V2)
##
## N R
## 151 47
rownames(dataBreast) <- dataBreast$V1
dataBreast$V1 <- NULL
dataBreast$status <- 1*(dataBreast$V2=="R")
dataBreast$V2 <- NULL
dataBreast$time <- dataBreast$V3
dataBreast$V3 <- NULL
dataBreast <- sapply(dataBreast,as.numeric)
## Warning in lapply(X = X, FUN = FUN, ...): NAs introduced by coercion
dataBreast <- as.data.frame(dataBreast[complete.cases(dataBreast),])
table(dataBreast$status)
##
## 0 1
## 148 46
Exploring Raw
Features with RRPlot
convar <- colnames(dataBreast)[lapply(apply(dataBreast,2,unique),length) > 10]
convar <- convar[convar != "time"]
topvar <- univariate_BinEnsemble(dataBreast[,c("status",convar)],"status")
pander::pander(topvar)
| 0.0261 |
0.0261 |
0.0261 |
0.0623 |
0.126 |
0.126 |
0.126 |
topv <- min(5,length(topvar))
topFive <- names(topvar)[1:topv]
RRanalysis <- list();
idx <- 1
topf <- topFive[1]
for (topf in topFive)
{
RRanalysis[[idx]] <- RRPlot(cbind(dataBreast$status,dataBreast[,topf]),
atProb=c(0.90,0.80),
timetoEvent=dataBreast$time,
title=topf,
# plotRR=FALSE
)
idx <- idx + 1
}















names(RRanalysis) <- topFive
Reporting the
Metrics
pander::pander(RRanalysis[[1]]$keyPoints,caption=topFive[1])
V35
| @:0.9 |
1.00e+01 |
1.33 |
0.152 |
0.89189 |
0.522 |
| @:0.8 |
3.00e+00 |
2.50 |
0.478 |
0.79730 |
0.638 |
| @MAX_BACC |
4.00e+00 |
2.64 |
0.478 |
0.81081 |
0.645 |
| @MAX_RR |
4.00e+00 |
2.64 |
0.478 |
0.81081 |
0.645 |
| @SPE100 |
-9.53e-09 |
1.00 |
1.000 |
0.00676 |
0.503 |
pander::pander(RRanalysis[[2]]$keyPoints,caption=topFive[2])
V24
| @:0.9 |
25.4 |
1.94 |
0.239 |
0.8919 |
0.566 |
| @:0.8 |
24.0 |
1.72 |
0.348 |
0.7973 |
0.573 |
| @MAX_BACC |
20.3 |
2.45 |
0.739 |
0.5270 |
0.633 |
| @MAX_RR |
16.6 |
3.87 |
0.957 |
0.1824 |
0.569 |
| @SPE100 |
15.5 |
33.04 |
1.000 |
0.0878 |
0.544 |
RRanalysis[[2]]$keyPoints["@MAX_BACC",c("BACC","RR")]
BACC RR
@MAX_BACC 0.6330787 2.451923
ROCAUC <- NULL
CstatCI <- NULL
RRatios <- NULL
LogRangp <- NULL
Sensitivity <- NULL
Specificity <- NULL
MAXBACC <- NULL
for (topf in topFive)
{
CstatCI <- rbind(CstatCI,RRanalysis[[topf]]$c.index$cstatCI)
RRatios <- rbind(RRatios,RRanalysis[[topf]]$RR_atP)
LogRangp <- rbind(LogRangp,RRanalysis[[topf]]$surdif$pvalue)
Sensitivity <- rbind(Sensitivity,RRanalysis[[topf]]$ROCAnalysis$sensitivity)
Specificity <- rbind(Specificity,RRanalysis[[topf]]$ROCAnalysis$specificity)
ROCAUC <- rbind(ROCAUC,RRanalysis[[topf]]$ROCAnalysis$aucs)
MAXBACC <- rbind(MAXBACC,RRanalysis[[topf]]$keyPoints["@MAX_BACC",c("BACC")])
}
rownames(CstatCI) <- topFive
rownames(RRatios) <- topFive
rownames(LogRangp) <- topFive
rownames(Sensitivity) <- topFive
rownames(Specificity) <- topFive
rownames(ROCAUC) <- topFive
rownames(MAXBACC) <- topFive
pander::pander(ROCAUC)
| V35 |
0.643 |
0.548 |
0.737 |
| V24 |
0.633 |
0.542 |
0.724 |
| V34 |
0.659 |
0.573 |
0.746 |
| V7 |
0.609 |
0.514 |
0.704 |
| V16 |
0.598 |
0.504 |
0.692 |
pander::pander(CstatCI)
| V35 |
0.629 |
0.629 |
0.534 |
0.718 |
| V24 |
0.677 |
0.679 |
0.601 |
0.748 |
| V34 |
0.660 |
0.661 |
0.590 |
0.730 |
| V7 |
0.666 |
0.666 |
0.586 |
0.745 |
| V16 |
0.614 |
0.617 |
0.529 |
0.703 |
pander::pander(RRatios)
| V35 |
1.44 |
0.741 |
2.82 |
| V24 |
1.93 |
1.122 |
3.31 |
| V34 |
1.44 |
0.741 |
2.82 |
| V7 |
1.37 |
0.700 |
2.69 |
| V16 |
1.04 |
0.462 |
2.32 |
pander::pander(LogRangp)
| V35 |
9.35e-05 |
| V24 |
9.38e-03 |
| V34 |
1.59e-03 |
| V7 |
7.33e-02 |
| V16 |
2.13e-02 |
pander::pander(Sensitivity)
| V35 |
0.152 |
0.0634 |
0.289 |
| V24 |
0.239 |
0.1259 |
0.388 |
| V34 |
0.152 |
0.0634 |
0.289 |
| V7 |
0.152 |
0.0634 |
0.289 |
| V16 |
0.109 |
0.0362 |
0.236 |
pander::pander(Specificity)
| V35 |
0.899 |
0.838 |
0.942 |
| V24 |
0.899 |
0.838 |
0.942 |
| V34 |
0.899 |
0.838 |
0.942 |
| V7 |
0.899 |
0.838 |
0.942 |
| V16 |
0.899 |
0.838 |
0.942 |
pander::pander(MAXBACC)
| V35 |
0.645 |
| V24 |
0.633 |
| V34 |
0.649 |
| V7 |
0.621 |
| V16 |
0.614 |
meanMatrix <- cbind(ROCAUC[,1],CstatCI[,1],Sensitivity[,1],Specificity[,1],RRatios[,1],MAXBACC)
colnames(meanMatrix) <- c("ROCAUC","C-Stat","Sen","Spe","RR","MAX_BACC")
pander::pander(meanMatrix)
| V35 |
0.643 |
0.629 |
0.152 |
0.899 |
1.44 |
0.645 |
| V24 |
0.633 |
0.677 |
0.239 |
0.899 |
1.93 |
0.633 |
| V34 |
0.659 |
0.660 |
0.152 |
0.899 |
1.44 |
0.649 |
| V7 |
0.609 |
0.666 |
0.152 |
0.899 |
1.37 |
0.621 |
| V16 |
0.598 |
0.614 |
0.109 |
0.899 |
1.04 |
0.614 |
Modeling
ml <- BSWiMS.model(Surv(time,status)~1,data=dataBreast,NumberofRepeats = 10)
[++++++++++++++++++++++++++++++++++++++++++++++++++]…..
sm <- summary(ml)
pander::pander(sm$coefficients)
Table continues below
| V24 |
5.66e-02 |
1.02 |
1.06 |
1.10 |
0.598 |
0.237 |
| V27 |
2.26e-04 |
1.00 |
1.00 |
1.00 |
0.608 |
0.282 |
| V26 |
3.85e-03 |
1.00 |
1.00 |
1.01 |
0.593 |
0.359 |
| V34 |
1.21e-02 |
1.00 |
1.01 |
1.02 |
0.634 |
0.304 |
| V7 |
6.57e-08 |
1.00 |
1.00 |
1.00 |
0.588 |
0.237 |
| V35 |
3.68e-03 |
1.00 |
1.00 |
1.01 |
0.727 |
0.598 |
Table continues below
| V24 |
0.598 |
0.609 |
0.500 |
0.609 |
0.0619 |
0.437 |
2.87 |
| V27 |
0.609 |
0.608 |
0.513 |
0.607 |
0.0562 |
0.434 |
2.76 |
| V26 |
0.599 |
0.598 |
0.535 |
0.603 |
0.0619 |
0.397 |
2.75 |
| V34 |
0.629 |
0.618 |
0.519 |
0.617 |
0.0307 |
0.461 |
2.38 |
| V7 |
0.588 |
0.595 |
0.500 |
0.595 |
0.0487 |
0.380 |
2.30 |
| V35 |
0.617 |
0.641 |
0.602 |
0.609 |
0.0280 |
0.551 |
2.25 |
| V24 |
2.67 |
0.10914 |
1.0 |
| V27 |
2.63 |
0.09444 |
1.0 |
| V26 |
2.41 |
0.06741 |
1.0 |
| V34 |
2.79 |
0.09788 |
1.0 |
| V7 |
2.30 |
0.09489 |
0.9 |
| V35 |
3.41 |
0.00704 |
0.9 |